﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SW2A311A
{
    public class MicrowaveOven : ElectricOven
    {
        #region Instansvariabler
        public bool WithGrill { get; private set; }
        public bool ConvectionOven { get; private set; }
        #endregion

        #region Constructors
        public MicrowaveOven(string name, double price, Dimensions dimension,
            double volume, double energyConsumption, bool withGrill, bool convectionOven)
            : base(name, price, dimension, volume, energyConsumption)
        {
            WithGrill = withGrill;
            ConvectionOven = convectionOven;
            Smiley = GetSmiley();
        }
        #endregion

        #region Metoder
        public override ESmiley GetSmiley()
        {
            if (this.WithGrill)
                return ESmiley.Neutral;
            else
                return ESmiley.Negative;
        }

        public override string ToString()
        {
            return string.Format
                ("Type: Microwave Oven\nManufacturer: {0}\nWith grill function: {1}\nWith convection: {2}\nVolume; {3}L\n" +
                "Energyconsumption: {4}kWh\nEnergyclass: {5}\nDimensionens: {6}\nSmiley: {7}\nPrice: {8:C}\n",
                Name, WithGrill ? "Yes" : "No", ConvectionOven ? "Yes" : "No",
                Volume, EnergyConsumption, EnergyClass, Dimension, Smiley, Price);
        }

        #region Equals-metoder
        // Override af Equals metoden. Den tester om objektet metoden kaldes på er værdi-mæssigt ens med indput parameter objektet.
        // Sammenligning med et object (hvis typen ikke kendes).
        public override bool Equals(object obj)
        {
            MicrowaveOven p = obj as MicrowaveOven;

            if (this.GetType() != obj.GetType())
                return false;

            return base.Equals(obj) &&
                WithGrill == p.WithGrill &&
                ConvectionOven == p.ConvectionOven;
        }

        // Sammenligning med en anden ElectricOven hvor typen kendes.
        public bool Equals(MicrowaveOven p)
        {
            return base.Equals((ElectricOven)p) &&
                WithGrill == p.WithGrill &&
                ConvectionOven == p.ConvectionOven;
        }

        // GetHashCode skal overrides sammen med Equals. Vi generer en seudo-telfældig hash kode.
        public override int GetHashCode()
        {
            return base.GetHashCode() ^
                WithGrill.GetHashCode() ^
                ConvectionOven.GetHashCode();
        }
        #endregion
        #endregion
    }
}
